package cn.gzjp.modules.gas.service;

import java.util.List;

import cn.gzjp.modules.logis.entity.LogisUser;
import cn.gzjp.modules.logis.service.LogisUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.gzjp.common.persistence.Page;
import cn.gzjp.common.service.CrudService;
import cn.gzjp.modules.gas.entity.GasRecharge;
import cn.gzjp.modules.gas.dao.GasRechargeDao;

/**
 * 充值Service
 * @author zengcp
 * @version 2018-03-12
 */
@Service
@Transactional(readOnly = true)
public class GasRechargeService extends CrudService<GasRechargeDao, GasRecharge> {
	@Autowired
	LogisUserService logisUserService;

	public GasRecharge get(String id) {
		return super.get(id);
	}
	
	public List<GasRecharge> findList(GasRecharge gasRecharge) {
		return super.findList(gasRecharge);
	}
	
	public Page<GasRecharge> findPage(Page<GasRecharge> page, GasRecharge gasRecharge) {
		return super.findPage(page, gasRecharge);
	}
	
	@Transactional(readOnly = false)
	public void save(GasRecharge gasRecharge) {
		LogisUser user = logisUserService.get(gasRecharge.getOpenid());
		if(user!=null){
			gasRecharge.setUnionId(user.getUnionId());
		}
		super.save(gasRecharge);
	}
	
	@Transactional(readOnly = false)
	public void delete(GasRecharge gasRecharge) {
		super.deleteByLogic(gasRecharge);
	}
	
}